{include file="public/head"/}
  
  <body>
    <div class="x-body">
        <form class="layui-form" action="{:url('admin/Repair/repairImage')}" method="post" enctype="multipart/form-data">
            <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>照片:
                    </label>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="image">上传图片</button>
                </div>
                <div class="layui-upload-list">
                  <img class="layui-upload-img" id="demo1" width="100px" height="100px">
                  <p id="demoText"></p>
                </div>
            </div> 
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  提交报修
              </button>
          </div>
      </form>
    </div>
    <script>
        layui.use('upload', function(){
            var $ = layui.jquery
            ,upload = layui.upload;
            
            //普通图片上传
            var uploadInst = upload.render({
                elem: '#image'
                ,url: 'admin/Property/roomAdd'
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code > 0){
                        return layer.msg('上传失败');
                    }
                    //上传成功
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
            });   
        }); 
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>

</html>